import { ApiConsumes, ApiTags } from '@nestjs/swagger'
import { Controller, Post, UseInterceptors, UploadedFile } from '@nestjs/common'
import { FileInterceptor } from '@nestjs/platform-express'
import { ApiFile, ApiAuth } from '@/common/decorators'
import { UploadInterceptor } from '@/common/interceptors'

@ApiAuth()
@ApiTags('UploadController')
@Controller('/upload')
export class UploadController {
  @ApiConsumes('multipart/form-data')
  @ApiFile()
  @Post('/')
  @UseInterceptors(FileInterceptor('file'), UploadInterceptor)
  upload(@UploadedFile() file: any): string {
    return file.path
  }
}
